package org.snowin.common;


import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.snowin.utils.GlobalInfo;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class FindCaseNames {
      String sp = GlobalInfo.getFileSeparator();
    public List<String> findCaseList() {
        List<String> caseList = new ArrayList<>();
        SAXReader saxReader = new SAXReader();
        Document doc = null;

        try {
            doc = saxReader.read(new File(GlobalInfo.getRootPath() + sp + GlobalInfo.ConfigXMLName + sp +GlobalInfo.CaseXMLName));
        } catch (DocumentException e) {
            e.printStackTrace();
        }
        List<Element> caseElList = doc.selectNodes("//CaseList/*");
        for (Element e : caseElList)
        {
            String caseName = e.attributeValue("name");
            String module = e.attributeValue("module");
            String type = e.attributeValue("type");
            caseList.add(caseName + ":" + module + ":" + type);
        }
        return caseList;

    }

}
